import sys
sys.path.append("../")
from Dataloader.weiboloader import WeiboLoader, topics
import pandas

def obtain_Domain_set(new_domain_id, topic_csv="../data/weibo_ids.csv"):
    df = pandas.read_csv(topic_csv)
    nd_df = df[df['category'] == new_domain_id]
    weibo_dir = "../data/Weibo"
    nd_set = WeiboLoader()
    nd_set.load_data(weibo_dir=weibo_dir,
                  weibo_df=nd_df, cached_prefix=None)
    dev, te = nd_set.split(percent=[0.5, 1.0])


    od_df = df[df['category'] != new_domain_id]
    od_set = WeiboLoader()
    od_set.load_data(weibo_dir=weibo_dir,
                      weibo_df=od_df, cached_prefix=None)

    tr_prefix, dev_prefix, te_prefix = "../data/weibo_tr_%s" % topics[new_domain_id], \
                                        "../data/weibo_dev_%s" % topics[new_domain_id], \
                                            "../data/weibo_te_%s" % topics[new_domain_id]
    od_set.Caches_Data(tr_prefix)
    dev.Caches_Data(dev_prefix)
    te.Caches_Data(te_prefix)

for domain_id in [1, 5, 6]:
    obtain_Domain_set(domain_id)

